<template>
  <div class="butt-list-sty">
    <div v-for="(item,index) in buttonselectlist" :key="index" :class="index === selectedindex ? 'basebut1':'basebut2'" @click="selbut(item, index)">
      {{ item.value }}
    </div>
  </div>
</template>
<script>
export default {
  props: {
    buttonselectlist: {
      type: Array,
      default: () => [
        { name: "总产量" },
        { name: "亩均产量" }
      ]
    }
  },
  data() {
    return {
      selectedindex: 0
    }
  },
  mounted() {
    this.selbut(this.buttonselectlist[0], 0)
  },
  methods: {
    selbut(item, i) {
      this.selectedindex = i
      // console.log(i)
      this.$emit('topitemtype', item.name)
    }
  }
}
</script>
<style lang="scss" scoped>
.butt-list-sty{
    width: 100%;
    height: 30px;
    display: flex;
    flex-direction: row;
    margin-bottom: 12px;
}
.basebut1 {
    width: 120px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    // background-color: transparent;
    background-image: linear-gradient(#0fa1d2,#1087af,#106f8f);
    border: #f6f9f9 1px solid;
    border-radius: 15px;
    color: #ffffff;
    cursor: pointer;
    margin: 3px 5px;
}
.basebut2 {
    width: 120px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: #106986;
    border-radius: 15px;
    color: #ffffff;
    cursor: pointer;
    margin: 3px 5px;
    padding-left: 10px;
    padding-right: 10px;
}
</style>
